#!/bin/bash
Temp=`hostname -s|grep lxslc6`
if [ "T$Temp" = "T" ]
then
        #echo Temp is not lxslc6

ps -eo pid,user,cputime,%cpu,command |egrep -v -w "(' root '|rpc|rpcuser|mysql|ntp|smmsp|xfs|daemon|gdm|postfix|argorec|argod|scp|paw|cc|gcc|f77|niejy|swtest|offline|maggiora|mdestefa)" |awk -F' ' {'if ((($3<"00:45:00") && ($3>"00:35:00" )) && ($4+0>"60"+0)) {  system("echo \"Your process " $1 " (" $5 ") has occupied too many resources, which will be killed. \"> /tmp/"$1"_warn_nokill" ); system("/afs/ihep.ac.cn/u07/public/system/warn -u  " $2 " /tmp/"$1"_warn_nokill"); system("date"); print $1 " " $2 " " $3 " " $4 " " $5}'} >>/var/log/kill_process.log

else  #if lxslc6

ps -eo pid,user,cputime,%cpu,command |egrep -v -w "(' root '|rpc|rpcuser|mysql|ntp|smmsp|xfs|daemon|gdm|postfix|salaman|stefanomaria|scp|paw|cc|gcc|f77|niejy|swtest|offline|maggiora|mdestefa)" |awk -F' ' {'if ((($3<"00:30:00") && ($3>"00:20:00")) && ($4>"60")) {system("echo \"Your process " $1 " (" $5 ") has occupied too many resources, which will be killed. \"> /tmp/"$1"_warn_nokill" ); system("/afs/ihep.ac.cn/u07/public/system/warn -u  " $2 " /tmp/"$1"_warn_nokill"); system("date"); print $1 " " $2 " " $3 " " $4 " " $5}'} >>/var/log/kill_process.log

fi
